<template>
	<view class="wrap">
		<view class="tabNav">
			<view class="tabItem"
				:class="[currIndex == index ? 'active' : '']"
				v-for="(item,index) in dealStatusArr"
				:key="index"
				@tap="switchStatus(index,item.id)"
			>{{item.name}}<view class="lineView"></view></view>
		</view>
		<block v-if="isHasDataFlag">
			<view class="innerItem"
				v-for="(item,index) in feedList"
				:key="index"
				@tap="goDet(item.id)"
			>
				<view class="feedTime spaceBet">
					<view><text class="iconfont icon-jubao" v-if="fromPage=='illegalReport'"></text>{{item.addTime}}</view>
					<view class="tag hasDeal" v-if="item.dealStatus == 3">已完结</view>
				</view>
				<block v-if="fromPage=='illegalReport'">
					<view class="feedCon">被举报人名:{{item.bjbRealName}}咨询师</view>
					<view class="feedCon">被举报账号:{{item.bjbAccount}}</view>
				</block>
				<view class="feedCon" v-if="item.type == 1">内容:{{item.content}}</view>
			</view>
		</block>
		<block v-else-if="isHasDataFlag == false">
			<no-data></no-data>
		</block>
		<!-- #ifdef MP-WEIXIN -->
		<view class="iconfont icon-jia" @tap="addFun" v-if="fromPage == 'feedBack'"></view>
		<!-- #endif -->
	</view>
</template>

<script>
	import { getFeedBackList } from '@/api/mine/index'
	export default{
		data(){
			return{
				isRefreshFlag:false,
				dealStatusArr:[{id:1,name:'未处理'},{id:2,name:'处理中'},{id:3,name:'已完结'}],
				currIndex:0,
				dealStatusVal:1,
				feedList:[],
				isHasDataFlag:null,
				fromPage:'',
				type:-1
			}
		},
		onLoad(options){
			this.fromPage = options.fromPage;
			var title = this.fromPage == 'feedBack' ? '我的反馈' : '我的举报';
			this.type = this.fromPage == 'feedBack' ? 1 : 2;
			setTimeout(()=>{
				uni.setNavigationBarTitle({
					title:title
				})
			},500)
			this.loadMyFeedBackList();
		},
		onShow(){
			if(this.isRefreshFlag){
				this.initParams();
			}
		},
		onHide(){
			this.isRefreshFlag = false;
		},
		onPullDownRefresh : function(){
			this.initParams();
			uni.stopPullDownRefresh();
		},
		onReachBottom : function(){
			if( !this.loading ){
				this.loadMyFeedBackList();
			}
		},
		methods:{
			goDet(id){
				uni.navigateTo({
					url:'/pages/subMine/myFeedBack/feedBackDet?detId=' + id + '&type=' + this.type + '&fromPage=' + this.fromPage
				})
			},
			switchStatus(index,id){
				this.currIndex = index;
				this.dealStatusVal = id;
				this.initParams();
			},
			loadMyFeedBackList(){
				var field = { dealStatus:this.dealStatusVal,page:1,limit:10000,type:this.type };
				getFeedBackList(field).then(res=>{
					this.feedList = res.data.datas;
					this.isHasDataFlag = true;
				}).catch(err=>{
					this.isHasDataFlag=false;
				});
			},
			initParams(){
				this.feedList = [];
				this.loadMyFeedBackList();
			},
			onNavigationBarButtonTap(e){
				if(e.index == 0){
					this.commonJump();
				}
			},
			addFun(){
				this.commonJump();
			},
			commonJump(){
				uni.navigateTo({
					url:'../addFeedBack/addFeedBack?fromPage=' + this.fromPage + '&fbId='
				})
			}
		}
	}
</script>
<style lang="scss">
	page{
		background: $pss-bg-primary;
		margin-top: 90rpx;
	}
</style>
<style lang='scss' scoped>
	@import '@/static/scss/myFeedBack.scss';
	.tabNav{
		width: 100%;
		height: 90rpx;
		background: #fff;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 100;
		display: flex;
		.tabItem{
			width: 50%;
			height: 90rpx;
			line-height: 90rpx;
			font-size: 30rpx;
			color:$pss-text-color8 ;
			text-align: center;
			position: relative;
			.lineView{
				width: 10%;
				height: 10rpx;
				background:$pss-color-primary_1;
				position: absolute;
				left: 45%; 
				bottom: 10rpx;
				display: none;
				border-radius: 20rpx;
			}
			&.active{
				color: $pss-color-primary_1;
				font-weight: bold;
				font-size: $font-size32;
				.lineView{
					display: block;
				}
			}
		}
	}
</style>